]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
osdWindow: add setMonitor() to allow changing the monitor
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 18 Nov 2013 12:48:19 +0000 (13:48 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 20 Nov 2013 17:03:32 +0000 (18:03 +0100)
This is also exposed in the ShowOSD DBus method, the "monitor"
parameter may contain an integer to indicate the monitor number.
If the value is not provided or <0 is used, the monitor is shown
on the primary monitor as usually.

This way, the OSD can be used to notify upon events that solely
apply to one monitor, like tablet mapping as discussed in
https://bugzilla.gnome.org/show_bug.cgi?id=710373.

https://bugzilla.gnome.org/show_bug.cgi?id=712664

js/ui/osdWindow.js
js/ui/shellDBus.js

index bb7d88894983a4b2e03b0b20702b8fb6aa50b4c0..24f78b45d731ff6bb1e0d6cfc4204d96e2e77a82 100644 (file)
@@ -77,7 +77,8 @@ const OsdWindow = new Lang.Class({
                                      y_expand: true,
                                      x_align: Clutter.ActorAlign.CENTER,
                                      y_align: Clutter.ActorAlign.CENTER });
-        this.actor.add_constraint(new Layout.MonitorConstraint({ primary: true }));
+        this._currentMonitor = undefined;
+        this.setMonitor (-1);
         this._box = new St.BoxLayout({ style_class: 'osd-window',
                                        vertical: true });
         this.actor.add_actor(this._box);
@@ -182,7 +183,13 @@ const OsdWindow = new Lang.Class({
 
     _monitorsChanged: function() {
         /* assume 110x110 on a 640x480 display and scale from there */
-        let monitor = Main.layoutManager.primaryMonitor;
+        let monitor;
+
+        if (this._currentMonitor >= 0)
+            monitor = Main.layoutManager.monitors[this._currentMonitor];
+        else
+            monitor = Main.layoutManager.primaryMonitor;
+
         let scalew = monitor.width / 640.0;
         let scaleh = monitor.height / 480.0;
         let scale = Math.min(scalew, scaleh);
@@ -206,5 +213,23 @@ const OsdWindow = new Lang.Class({
         let minHeight = this._popupSize - horizontalPadding - topBorder - bottomBorder;
 
         this._box.style = 'min-height: %dpx;'.format(Math.max(minWidth, minHeight));
+    },
+
+    setMonitor: function(index) {
+        let constraint;
+
+        if (index < 0)
+            index = -1;
+        if (this._currentMonitor == index)
+            return;
+
+        if (index < 0)
+            constraint = new Layout.MonitorConstraint({ primary: true });
+        else
+            constraint = new Layout.MonitorConstraint({ index: index });
+
+        this.actor.clear_constraints();
+        this.actor.add_constraint(constraint);
+        this._currentMonitor = index;
     }
 });
index 79ff46cba29efdf6d161439326b41e957e1ad4ef..4049095a9c9a2846ac02a16659047769cae63bd8 100644 (file)
@@ -133,11 +133,16 @@ const GnomeShell = new Lang.Class({
         for (let param in params)
             params[param] = params[param].deep_unpack();
 
+        let monitorIndex = -1;
+        if (params['monitor'])
+            monitorIndex = params['monitor'];
+
         let icon = null;
         if (params['icon'])
             icon = Gio.Icon.new_for_string(params['icon']);
 
         Main.osdWindow.setIcon(icon);
+        Main.osdWindow.setMonitor (monitorIndex);
         Main.osdWindow.setLabel(params['label']);
         Main.osdWindow.setLevel(params['level']);